package evs.testiap;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import evs.brp.RemotingErrorException;

public class TestClient {
	
	private Log log = LogFactory.getLog(TestClient.class);
	
	public void printSyntax() {
		System.err.println("Syntax: TestClient ServerURI");
		System.exit(-1);
	}	
	
	public static void main(String[] args) {
		TestClient testClient = new TestClient();
		
		if(args.length != 1)
			testClient.printSyntax();
		
		testClient.runTestSuite(args[0]);
	}
	
	/**
	 * 
	 * +++++++++++++++++++++++++++++++
	 * 
	 * if testclient is run multiple times -> counters get higher because currently no sort of lifecycle management / garbage collector is implemented
	 * 
	 * +++++++++++++++++++++++++++++++
	 * 
	 */
	public void runTestSuite(String serverUri) {
		
		LongPrinterProxy proxy_A_1 = new LongPrinterProxy();
		
		try {
			log.info("------ before");
			proxy_A_1.bind(new URI(serverUri + "/LongPrinter"));
			log.info("------ after");			
			proxy_A_1.print("testm");
			
			proxy_A_1.unbind();
		
		} 
		catch (Exception exc) {
			exc.printStackTrace();
			log.error(exc);
		}
	}
}
